import { useSettingStore } from '@renderer/stores';
import { useSearchSnippets } from './useSearchSnippets';

export function useSearchDefault () {
  const defaultSearchType = useSettingStore(s => s.defaultSearchType)
  const systemSearchItems = useSettingStore(s => s.systemSearchItems)
  const browserSearchItems = useSettingStore(s => s.browserSearchItems)
  const { searchSnippets } = useSearchSnippets()
  
  const searchDefault = (keyword: string) => {
    const defaultItem = [
      ...systemSearchItems,
      ...browserSearchItems,
    ].find(i => {
      return i.type === defaultSearchType
    })!

    switch (defaultItem.type) {
      case 'ip':
        break
      case 'datetime':
        break
      case 'snippets':
        searchSnippets(keyword)
    }
  }

  return {
    searchDefault,
  }
}
